import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'


import panelHead from '@/components/panelHead.vue'

router.beforeEach((to) =>{
  const token = localStorage.getItem('pz_token')
  if (!token && to.path !== '/login') {
    return '/login'
  }else if(token && to.path === '/login') {
    return '/'
  }else{
    return true
  }
})

import * as ElementPlusIconsVue from '@element-plus/icons-vue'
const app = createApp(App)

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.component("panelHead", panelHead)

app.use(createPinia())

app.use(router)

app.mount('#app')
